//
//  ChooseLoginModeViewController.m
//  Fangmm
//
//  Created by 阮琦 on 16/3/10.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "ChooseLoginModeViewController.h"
#import "MobileLoginViewController.h"
#import "ACMacros.h"
#import "WXApi.h"

#import <TSMessage.h>
#import <MobClick.h>

@interface ChooseLoginModeViewController () <WXApiDelegate>

@end

@implementation ChooseLoginModeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self insertBackground];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewWillAppear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [MobClick beginLogPageView:@"PageOne"];
}

- (void)viewWillDisappear:(BOOL)animated {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    [MobClick endLogPageView:@"PageOne"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - Configuring the view’s layout behavior
- (void)insertBackground {
    UIImageView *backgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, Main_Screen_Width, Main_Screen_Height)];
    [backgroundImageView setImage:[UIImage imageNamed:@"login_bg.jpg"]];
    [self.view insertSubview:backgroundImageView atIndex:0];
}

- (IBAction)clickToMoreLoginMode:(UIButton *)sender {
    MobileLoginViewController *mobileLoginVC = [[MobileLoginViewController alloc]initWithNibName:@"MobileLoginViewController" bundle:nil];
//    [self.navigationController pushViewController:mobileLoginVC animated:true];
    [self presentViewController:mobileLoginVC animated:true completion:^{
        
    }];
}
- (IBAction)wxAuthLogin:(UIButton *)sender {
    if ([WXApi isWXAppInstalled]) {
        [self sendAuthRequest];
    } else {
        [TSMessage showNotificationInViewController:self title:@"您并没有安装微信客户端!" subtitle:@"请安装微信客户端或用其他方式登陆" type:TSMessageNotificationTypeWarning duration:2.0 canBeDismissedByUser:true];
    }
}

- (void)sendAuthRequest
{
    //构造SendAuthReq结构体
    SendAuthReq *req = [[SendAuthReq alloc]init];
    req.scope = @"snsapi_userinfo" ;
    req.state = @"123" ;
    //第三方向微信终端发送一个SendAuthReq消息结构
    [WXApi sendReq:req];
}

@end
